package com.ydgk.servlet;

import com.ydgk.bean.Book;
import com.ydgk.dao.BookDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "BookFindByIdServlet", urlPatterns = "/BookFindByIdServlet.action")
public class BookFindByIdServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String bid = request.getParameter("bid");
        String pageNumber = request.getParameter("pageNumber");
        BookDao bookDao = new BookDao();
        Book book = bookDao.findById(Integer.parseInt(bid));
        request.setAttribute("book",book);
        request.setAttribute("pageNumber",pageNumber);
        request.getRequestDispatcher("bookinformation.jsp?target='mainFrame'").forward(request,response);
    }


}
